package com.zj.classwork;
import java.util.Scanner;
import java.util.Arrays;


public class ClassWork23 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入一个字符串：");
        String value = input.next();
        char[] arr = value.toCharArray();
        System.out.print("原字符数列：");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + "\t");
        }
        System.out.println();
        Arrays.sort(arr);
        System.out.print("升序排序后：");
        for (int j = 0; j < arr.length; j++) {
            System.out.print(arr[j] + "\t");
        }
        System.out.println();
        System.out.println("待插入的字符：");
        String word= input.next();
        System.out.println("插入字符的下标");
        int flag= input.nextInt();
        char insertChar = word.charAt(0);
       char[]arr2=Arrays.copyOf(arr,arr.length+1);
        for(int t=flag;t<arr2.length;t++)
        {
            arr2[t]=arr[t-1];
        }
        arr2[flag-1]=insertChar;
        for (int u=0;u<arr2.length;u++)
        {
            System.out.print(arr2[u]+"\t");
        }

    }
}
